
# find the OS
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')

# Compile flags for linux / osx
ifeq ($(uname_S),Linux)
	DEFINES=-DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE -D_GNU_SOURCE -D_LARGEFILE64_SOURCE
	#SHOBJ_CFLAGS ?= -W -Wall -fno-common -g -ggdb -std=c99 -O2
	SHOBJ_CFLAGS ?=  -fno-common -g -ggdb -std=c99
	SHOBJ_LDFLAGS ?= -shared
else
	#SHOBJ_CFLAGS ?= -W -Wall -dynamic -fno-common -g -ggdb -std=c99 -O2
	SHOBJ_CFLAGS ?=  -dynamic -fno-common -g -ggdb -std=c99
	SHOBJ_LDFLAGS ?= -bundle -undefined dynamic_lookup
endif

OBJS = ../../public/cJSON.xo \
        pt_auth_relate_module.xo

OBJS_dict = ../../public/cJSON.xo \
        pt_dict_module.xo
	
	
OBJS_fz = cJSON.xo \
        TJ_MWM.xo \
        pt_fz_center_2.0_thread.xo

OBJS_mwm = TJ_MWM.xo \
        ../../public/cJSON.xo \
        pt_fz_center.xo
		
.SUFFIXES: .c .so .xo .o

#all: pt_auth_relate_center.so pt_dict_center.so  pt_mwm_center.so  
#all: pt_mwm_center.so   pt_dict_center.so
#INCS=-I ../../include/ -I ../../include/zookeeper -I ../../public -I../../include/tokyocabinet
all:pt_fz_center.so


.c.xo:
	$(CC)  $(CFLAGS) $(DEFINES) $(SHOBJ_CFLAGS) -fPIC -c  -I. -I../../include/ -I../../include/tokyocabinet   $< -o $@

#pt_auth_relate_module.xo

cJSON.xo: cJSON.h 

LIBS= libtokyocabinet.a

#pt_auth_relate_center.so: $(OBJS)
#	$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc

pt_dict_center.so: $(OBJS_dict)
	$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc	
		
pt_fz_center.so: $(OBJS_fz)
	$(LD) -lbz2 -lz  -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc 	

pt_mwm_center.so: $(OBJS_mwm)
	$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc 	
clean:
	rm -rf *.xo *.so  ../../public/cJSON.xo
